#include <stdio.h>
#include <string.h>

char *mystrstr(const char *haystack, const char *needle)
{
	int sublen = 0;
	int i;
	
	sublen = strlen(needle);  //获取查找子串的长度

	while (*haystack) {
		if (*haystack == *needle) {
			for(i = 1; i < sublen; ++i)
			{
				if( *(haystack + i) != *(needle + i))
				  break;
			}
			if (i == sublen)
			  return haystack;
		}

		//指针后移
		haystack++;
	}
	
	//到达\0退出循环
	return (char*)NULL;
}

int main(void)
{
	char *str =  "Hello,world";
	char *sub = "lle";

	printf("%s\n",strstr(str,sub));
	return 0;
}
